We all know that data validation is a very useful feature in Excel. You can use data validation to create a drop-down list in a cell and limit the values user can enter. But, do you know that you can use data validation in a multitude of ways to prevent users from entering wrong data?
Here is a practical application: Prevent users from entering duplicate values in a range of cells.
For eg. you are making an invoice. Wouldn’t it be cool if Excel prompted you when you enter a duplicate line item so that increase the item quantity instead of repeating it.
Here is a 3 step tutorial to do just that.
Step 1: Identify the range of cells where you want only unique values to be entered
This is simple. All you have to do is find the range where you want to control the user input. Lets say the range is B4:B11
Step 2: Set up Data Validation to prevent duplicate entries
Select the range (B4:B11) and go to data validation (Excel 2007: Data Ribbon > Data Validation, or press ALT+AVV)
Now, specify the validation type as “Custom”, this will allow us to use formulas to check for valid data. In our case, we need check if a particular entry is duplicated in the range B4:B11. This can be easily done using COUNTIF formula [learn COUNTIF Formula in plain English].
Go to the formula field and type the countif formula like this: =COUNTIF($B$4:$B$11,B4)<=1
Also, you can set up the “Error Alert” so that you can show a custom message when a duplicate value is typed, like “You have already added that product” message.

Once you set up error message, it will show up like this:

Step 3: Sit back and Relax
The third step is all too familiar. Now that you have prevented duplicate entries in your spreadsheets you can sit back and relax. May be read a few more spreadcheats.
More kickass stuff on data validation (and working with duplicates) using excel
There are a ton of useful articles on the site related to data validation and working with duplicates using excel. Here is a sample. Get started and learn something useful today.
- Data Validation Tricks in Excel [with downloadable tutorial]
- Remove Duplicate Values from a Range in Excel
- Using Array formulas to find if a list has duplicates
- Working with duplicate items in Excel [several examples]
- Examples & Articles on Excel Data Validation
This post is part of our spreadcheats series (yes, the series is still going after one year 😛 )

















2 Responses to “Top 10 Power BI Interview Questions & Answers”
Hello...
In Power BI I have data that includes months by name only (e.g. May, April, December...)
I need to build charts etc. but i need the months to go chronologically... not alphabetically... I cannot seem to find the fix to this.... once again, my data does NOT have an actual date attached to it (like 02/01/2023)....only month names... can i use a helper table wher i id the month names as numbers 1 thru 12? and if so, how do i manage this to work for me ?
Thank you.
~Keith
You need to setup an extra table to map each month name to a running number. A simple 12 row table like
Jan 1
Feb 2
Mar 3
..
Dec 12
Then create a relationship between this month table and your month column
Now, go to "table view" in Power BI and set the sort by column to month number for the month name column on this new table.
Finally, use the new table's month name whenever you need to refer to the month name in the visuals.
They will be chronologically arranged.